class_name ItemPool
extends Resource

@export var available_items1_init: Array[PandoraEntity]
@export var available_items1: Array[PandoraEntity]
@export var available_items2: Array[PandoraEntity]
@export var available_items3: Array[PandoraEntity]
@export var available_items4: Array[PandoraEntity]

var available_level_1_init: Array[PandoraEntity]
var item_pool_level_1: Array[PandoraEntity]
var item_pool_level_2: Array[PandoraEntity]
var item_pool_level_3: Array[PandoraEntity]
var item_pool_level_4: Array[PandoraEntity]

func generate_item_pool() -> void:
	for unit: PandoraEntity in available_items1_init:
		available_level_1_init.append(unit.instantiate())
		
	for unit: PandoraEntity in available_items1:
		item_pool_level_1.append(unit.instantiate())
		
	for unit: PandoraEntity in available_items2:
		item_pool_level_2.append(unit.instantiate())
		
	for unit: PandoraEntity in available_items3:
		item_pool_level_3.append(unit.instantiate())
		
	for unit: PandoraEntity in available_items4:
		item_pool_level_4.append(unit.instantiate())			

## 随机挑选一个返回
func get_random_unit(level: int) -> PandoraEntity:
	if level == 1:
		if item_pool_level_1.size() == 0: 	
			return null
		return item_pool_level_1.pick_random()
	elif level == 2:
		if item_pool_level_2.size() == 0: 	
			return null
		return item_pool_level_2.pick_random()
	elif level == 3:
		if item_pool_level_3.size() == 0: 	
			return null
		return item_pool_level_3.pick_random()
	elif level == 4:
		if item_pool_level_4.size() == 0: 	
			return null
		return item_pool_level_4.pick_random()
	return null
